﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace WebSys
{
    public partial class test1 : System.Web.UI.Page
    {
        EluZSProvider.EluZSDataProvider _EluZSDataProvider = (EluZSProvider.EluZSDataProvider)Antu.Core.Services.ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            } 
        }

        protected void BindData() 
        {
            string strPId = base.Page.Request["PID"];
            if (!string.IsNullOrEmpty(strPId))
            {
                string sql = string.Format("Select n.Id,n.房屋坐落,n.产权人 所有权人,n.承租人 From Zs_Zsperson n Where 1 = 1 And (Pid = '{0}' Or Id In (Select Zspid From Zs_Zzbcjfenhu Where Pid In (Select Id From Zs_Prono Where Pid = '{0}')))", strPId);
                DataTable dt = _EluZSDataProvider.GetTable(sql);
                CustomGridList1.DataSource = dt;
                CustomGridList1.RecordCount = dt.Rows.Count;
                CustomGridList1.DataBind();
            }
        }
        protected void CustomGridList1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow) {
                DataRowView rowview = (DataRowView)e.Row.DataItem;
                string strId = rowview["ID"].ToString();
                string strPId = base.Page.Request["PID"];
                if (!string.IsNullOrEmpty(strPId))
                {
                    Literal 补偿面积 = (Literal)e.Row.FindControl("补偿面积");
                    Literal 补偿款 = (Literal)e.Row.FindControl("补偿款");
                    Literal 是否出评估报告 = (Literal)e.Row.FindControl("是否出评估报告");
                    Literal 是否拟定协议 = (Literal)e.Row.FindControl("是否拟定协议");
                    Literal 协议是否打印 = (Literal)e.Row.FindControl("协议是否打印");
                    Literal 是否审核通过 = (Literal)e.Row.FindControl("是否审核通过");
                    补偿面积.Text = _EluZSDataProvider.GetString(@"Select To_Number(Nvl(Replace(Textbox73, '\', ''), 0))
             From Zs_Hbhxy t
            Where t.Personid = '" + strId + @"'
              And Pnid =
(Select Id From Zs_Prono Where Pid = '" + strPId + "')");
                    补偿款.Text = _EluZSDataProvider.GetString(@"Select Nvl((Select To_Number(Nvl(Replace(Textbox19, '\', ''), 0))
             From Zs_Hbhxy t
            Where t.Personid = '" + strId + @"'
              And Pnid =
                  (Select Id From Zs_Prono Where Pid = '" + strPId + @"')),
           0) + Nvl((Select To_Number(Nvl(Replace(Textbox21, '\', ''), 0))
                      From Zs_Cqzhxy t
                     Where t.Fid In (Select Id
                                       From Zs_Proloupan
                                      Where Zid In
                                            (Select Id
                                               From Zs_Prozhuang
                                              Where Pnid = '" + strPId + @"')
                                        And Zspid = '" + strId + @"')),
                    0) From dual ");
                    是否出评估报告.Text = _EluZSDataProvider.GetString(@"Select (Case
         When (Select Count(*) From zs_zzbcjfenhu t Where zspid='" + strId + @"' And Pid In 
         (Select Id From zs_prono Where PId= '" + strPId + @"') ) > 0 Then
          '√'
         Else
          '  '
       End) From dual ");
                    是否拟定协议.Text = _EluZSDataProvider.GetString(@"Select (Case
         When Nvl((Select Count(*)
                    From Zs_Hbhxy t
                   Where t.Personid='" + strId + @"'
                     And Pnid =
                         (Select Id From Zs_Prono Where Pid = '" + strPId + @"')),
                  0) + Nvl((Select Count(*)
                             From Zs_Cqzhxy
                            Where Fid In (Select Id
                                            From Zs_Proloupan
                                           Where Zid In
                                                 (Select Id
                                                    From Zs_Prozhuang
                                                   Where Pnid = '" + strPId + @"')
                                             And Zspid = '" + strId + @"')),
                           0) > 0 Then
          '√'
         Else
          '  '
       End) From dual ");
                    协议是否打印.Text = _EluZSDataProvider.GetString(@"Select (Case
         When (Nvl((Select Sum(打印次数)
                     From Zs_Hbhxy t
                    Where t.Personid = '" + strId + @"'
                      And Pnid =
                          (Select Id From Zs_Prono Where Pid = '" + strPId + @"')),
                   0) + (Nvl((Select Sum(打印次数)
                                From Zs_Cqzhxy
                               Where Fid In
                                     (Select Id
                                        From Zs_Proloupan
                                       Where Zid In
                                             (Select Id
                                                From Zs_Prozhuang
                                               Where Pnid = '" + strPId + @"')
                                         And Zspid ='" + strId + @"')),
                              0))) > 0 Then
          '√'
         Else
          '  '
       End) From dual ");
                    是否审核通过.Text = _EluZSDataProvider.GetString(@"Select (Case
         When (Select Count(*)
                 From Zs_Hbhxy t
                Where t.Personid = '" + strId + @"'
                  And 审核状态 = 1
                  And Pnid =
                      (Select Id From Zs_Prono Where Pid = '" + strPId + @"')) > 0 Then
          '√'
         Else
          '  '
       End) From dual ");
                }
            }
        }
        protected void CustomGridList1_OnLoadData(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
